package com.securitytrace.dataModel;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.swing.DefaultComboBoxModel;
import com.securitytrace.model.Role;

public class RoleComBoxModel extends DefaultComboBoxModel {

	private static final long serialVersionUID = 3152214271572824988L;
	
	private static Map<String, Long> roleMap = new HashMap<String, Long>();

	@Override
	public Object getSelectedItem() {
		return super.getSelectedItem();
	}
	
	public void addItems(List<Role> roles) {
		for(Role role : roles) {
			if(roleMap.containsKey(role.getName())) {
				roleMap.remove(role.getName());
			}
			roleMap.put(role.getName(), role.getId());
			super.addElement(role.getName());
		}
	}
	/** 以下是get/set方法*/
	public static Map<String, Long> getRoleMap() {
		return roleMap;
	}
}
